$(document).ready(function(){
	$(".parent").change(function(){
		if ($(this).val() == 0)
		{
			$("#parent_bank").attr("disabled","disabled");
			$("#name").removeAttr("readonly");
			$("#fullname").removeAttr("readonly");
			$("#license").removeAttr("readonly");
			$("#cbrf_link").removeAttr("readonly");
			$("#site").removeAttr("readonly");
			$("#about").removeAttr("readonly");
			$("#info").removeAttr("readonly");
			$("#insert_city").removeAttr("disabled");
			$("#insert_city_rod").removeAttr("disabled");
			$("#insert_city_pred").removeAttr("disabled");
		}
		else
		{
			$("#parent_bank").removeAttr("disabled");
			load_bank_inf();
		}
	})
	$("#parent_bank").change(function(){
		load_bank_inf();
	})
})

function load_bank_inf(){
	var id = $("#parent_bank").val();
	$.ajax({
		url: "/admin/ajax_bank?bank_id="+id,
		success: function (data){
			request = $.parseJSON(data);
			$("#name").val(request.name).attr("readonly","readonly");
			$("#fullname").val(request.fullname).attr("readonly","readonly");
			$("#license").val(request.license).attr("readonly","readonly");
			$("#cbrf_link").val(request.link).attr("readonly","readonly");
			$("#site").val(request.site).attr("readonly","readonly");
			$("#about").val(request.about).attr("readonly","readonly");
			$("#info").val(request.info).attr("readonly","readonly");
			$("#insert_city").attr("disabled","disabled");
			$("#insert_city_rod").attr("disabled","disabled");
			$("#insert_city_pred").attr("disabled","disabled");
		}
	})
}